package com.example.mycloudpicture.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mycloudpicture.api.aliyunai.model.CreateOutPaintingTaskRequest;
import com.example.mycloudpicture.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.example.mycloudpicture.model.dto.picture.*;
import com.example.mycloudpicture.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.mycloudpicture.model.entity.User;
import com.example.mycloudpicture.model.vo.PictureVo;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author 黄宽亮
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-02-25 18:14:30
*/
public interface PictureService extends IService<Picture> {
    /**
     * 校验图片
     *
     * @param picture   图片
     */
    void validPicture(Picture picture);


    /**
     * 上传图片
     *
     * @param inputSource         文件输入源
     * @param pictureUploadRequest 上传请求
     * @param loginUser          当前登录用户
     * @return
     */
    PictureVo uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);

    /**
     * 获取图片包装类（单条）
     *
     * @param picture   图片
     * @param request 请求
     * @return
     */
    PictureVo getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 获取图片包装类（分页）
     *
     * @param picturePage 图片分页
     * @param request 请求
     * @return
     */
    Page<PictureVo> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

   /**
    * 获取查询对象
    * @param pictureQueryRequest 查询请求
    * @return
    */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 删除图片
     * @param pictureId 图片id
     * @param loginUser 当前登录用户
     */
    void deletePicture(long pictureId, User loginUser);

    /**
     * 图片审核
     * @param pictureReviewRequest 图片审核请求
     * @param loginUser            当前登录的 user
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 填充图片审核参数
     * @param picture 图片
     * @param loginUser 当前登录用户
    */
    void fillReviewParams(Picture picture, User loginUser);


    /**
     * 批量上传图片
     * @param pictureUploadByBatchRequest 批量抓取请求参数
     * @param loginUser 当前登录用户
     * @return 抓取数量
     */
    int uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser);

    /**
     * 清除cos图片
     * @param oldPicture 旧图片
     */
    void clearPicture(Picture oldPicture);

    /**
     * 检查图片权限
     * @param loginUser 当前登录用户
     * @param picture 图片
     */
    void checkPictureAuth(User loginUser,Picture picture);

    /**
     * 编辑图片
     * @param pictureEditRequest 编辑请求
     * @param loginUser 当前登录用户
     */
    void editPicture(PictureEditRequest pictureEditRequest, User loginUser);

    /**
     * 根据颜色搜索图片
     * @param spaceId 空间id
     * @param picColor 图片颜色
     * @param loginUser 当前登录用户
     * @return
     */
    List<PictureVo> searchPictureByColor(Long spaceId,String picColor,User loginUser);

    /**
     * 批量编辑图片
     * @param pictureEditByBatchRequest 批量编辑请求
     * @param loginUser  当前登录用户
     */
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    /**
     * 填充图片名称
     * @param pictureList 图片列表
     * @param nameRule 名称规则
     */
    void fillPictureWithNameRule(List<Picture> pictureList,String nameRule);


    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);
}
